<?php echo $this->Form->create('ordenes', array('action' => 'guardaOrden')); ?>
<div class="widget grid6">
    <div class="whead"><h6>FORMULARIO DE NUEVA ORDEN DE COMPRA</h6><div class="clear"></div></div>
    <div class="formRow">
        <div class="grid3"><label>Orden de compra (PO):</label></div>
        <div class="grid9">
            <?php echo $this->Form->text('nombre', array('placeholder' => 'Ingrese la Orden Ej: CA-009')); ?>
        </div>
        <div class="clear"></div>
    </div>

    <div class="formRow">
        <div class="grid3"><label>Fecha :</label></div>
        <div class="grid9">
            <?php echo $this->Form->text('fecha', array('id' => 'fechaPed', 'placeholder' => 'Ingrese la Fecha del Pedido Formato: (Ano-Mes-Dia)')); ?>
        </div>
        <div class="clear"></div>
    </div>

     <div class="formRow">
        <div class="grid3"><label>Monto :</label></div>
        <div class="grid9">
            <?php echo $this->Form->text('monto', array('placeholder' => 'Ingrese Monto')); ?>
        </div>
        <div class="clear"></div>
    </div>
    
    <div class="formRow">
        <div class="grid3"><label>Categoria :</label></div>
        <div class="grid9">
            <?php echo $this->Form->select('categoria_id', $dcc); ?>
        </div>
        <div class="clear"></div>
    </div>
    
    <div class="formRow">
        <div class="grid3"><label>Volumenes :</label></div>
        <div class="grid9">
            <?php echo $this->Form->text('volumenes', array('id' => 's4', 'value' => '0')); ?>                        
        </div>
        <div class="clear"></div>
    </div>

    <div class="formRow">
        <div class="grid3"><label>Original :</label></div>
        <div class="grid3">            
            <?php echo $this->Form->checkbox("original", array('value' => 1, 'hiddenField' => false)); ?>
        </div>
        
        <div class="grid3"><label>Cant Firmas :</label></div>
        <div class="grid3">            
             <?php echo $this->Form->text('firmasoriginal', array('value' => '0')); ?>
            <?php //echo $this->Form->checkbox("tagSel", array('value' => 1, 'hiddenField' => false)); ?>
        </div>
        <div class="clear"></div>
    </div>

    <div class="formRow">
        <div class="grid3"><label>Copia: </label></div>
        <div class="grid3">
            <?php echo $this->Form->checkbox("copia", array('value' => 1, 'hiddenField' => false)); ?>
        </div>
        <div class="grid3"><label>Cant. Firmas :</label></div>
        <div class="grid3">
             <?php echo $this->Form->text('firmascopia', array('value' => '0')); ?>
        </div>        
        <div class="clear"></div>
    </div>

    <div class="formRow">
        <div class="grid3"><label>Documentos :</label></div>                        
        <div class="grid9 check">
            <?php foreach ($documentos as $d): ?>
                <?php $idDoc = $d['Documento']['id']; ?>
                <?php //echo $this->Form->text("vol_$idDoc", array('size' => '2'))   ; ?> 
                <span class="grid3"><input type="text" name="g3" placeholder="Volumen" /></span>
                <?php echo $this->Form->checkbox("doc_$idDoc", array('value' => 1, 'hiddenField' => false)); ?>                
                <label for="check1" class="mr20"><?php echo $d['Documento']['nombre']; ?></label>              
                <p>&nbsp;</p>
            <?php endforeach; ?>
        </div>        
        <div class="clear"></div>
    </div>    
    
    <div class="formRow">
        <div class="grid3"><label>Observaciones :</label></div>
        <div class="grid9">
            <?php echo $this->Form->text('observaciones', array('placeholder' => 'Ingrese la Orden Ej: CA-009')); ?>
        </div>
        <div class="clear"></div>
    </div>

    <div class="formRow">
        <?php
        $options = array(
            'label' => 'Registrar nueva orden',
            'class' => 'buttonS bLightBlue',
            'id' => 'btEnvia'
        );
        echo $this->Form->end($options);
        ?> 
        <div class="clear"></div>
    </div>
</div>
<div class="clear"></div>

<div class="widget">
    <div class="whead"><h6>Listado de Tags</h6><div class="clear"></div></div>
    <div class="shownpars">
        <table cellpadding="0" cellspacing="0" border="0" class="dTable">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Codigo<span class="sorting" style="display: block;"></span></th>
                    <th>Descripcion 1</th>
                    <th>Descripcion 2</th>   
                    <th>
                        Seleccionar<?php echo $this->Form->text('Seleccionados', array('id' => 'seleccionados')); ?>
                    </th>
                </tr>
            </thead>
            <tbody>
                <?php //foreach ($tags as $t): ?>
                <tr class="gradeX">
                    <?php //$id = $t['Tag']['id']; ?>
                    <td><?php //echo $t['Tag']['id'];     ?></td>
                    <td><?php //echo $t['Tag']['codigo'];     ?></td>
                    <td><?php //echo $t['Tag']['descripcion1'];     ?></td>
                    <td><?php //echo $t['Tag']['descripcion2'];     ?></td>                   
                    <td><?php //echo $this->Form->checkbox("tagSel_$id", array('value' => $id, 'hiddenField' => false));     ?></td>
                </tr>
                <?php //endforeach; ?>                
            </tbody>
        </table>
    </div> 
</div>    

<div class="formRow">
    <?php
    $options = array(
        'label' => 'Registrar nueva orden',
        'class' => 'buttonS bLightBlue',
        'id' => 'btEnvia'
    );
    echo $this->Form->end($options);
    ?> 
    <div class="clear"></div>
</div>
<script>
    $(document).ready(function() {
        
        $( "#fechaPed" ).datepicker({
            defaultDate: +7,
            showOtherMonths:true,
            autoSize: true,
            /*appendText: '(Ano-Mes-Dia)',*/
            dateFormat: 'yy-mm-dd',
            changeMonth: true,
            changeYear: true
        });        
        /* Init the table */
        var oTable = $('.dTable').dataTable( );
        
        /* Add/remove class to a row when clicked on */
        $('.dTable tr').click( function() {
            $(this).toggleClass('row_selected');               
        } );
        
        $('#btEnvia').hover( function() {
            //$(this).toggleClass('row_selected');  
            var prodsMarcados = new Array();
            $("input[type=checkbox][name='data[ordenestags][tagSel_[]']:checked").each(function(){
                prodsMarcados.push($(this).next().text());
            });
            console.log("hizo click "+prodsMarcados);
        } );
            
    } );                 
    
</script>